{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "0cf8b073",
   "metadata": {},
   "source": [
    "# 🛠️ Self‑Healing Repo · Colab Notebook\n",
    "See an agent detect failing tests, generate a patch, and heal the codebase—right in Colab."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "e7d2e163",
   "metadata": {},
   "source": [
    "## 1 · Clone Alpha‑Factory & install lean deps (≈2 min)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "9d65bd78",
   "metadata": {},
   "outputs": [],
   "source": [
    "\n",
    "!git clone --depth 1 https://github.com/MontrealAI/AGI-Alpha-Agent-v0.git -q\n",
    "%cd AGI-Alpha-Agent-v0/alpha_factory_v1/demos/self_healing_repo\n",
    "!pip -q install pytest gradio openai_agents patch tensorflow==2.15 --extra-index-url https://download.pytorch.org/whl/cpu\n"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "ec99722d",
   "metadata": {},
   "source": [
    "## 2 · (Optional) Add your OpenAI API key for GPT‑4o reasoning"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "8e73217d",
   "metadata": {},
   "outputs": [],
   "source": [
    "import os\n",
    "os.environ['OPENAI_API_KEY'] = ''  # paste or leave blank for offline Mixtral"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "4f21232b",
   "metadata": {},
   "source": [
    "## 3 · Launch dashboard (public link will appear below)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "e13b7473",
   "metadata": {},
   "outputs": [],
   "source": [
    "!python agent_selfheal_entrypoint.py"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "4f4566d7",
   "metadata": {},
   "source": [
    "When the cell prints the Gradio public URL, click it to open the interactive UI.\n",
    "\n",
    "*Try pressing **Heal Repository** to watch the agent patch the bug and rerun tests.*"
   ]
  }
 ],
 "metadata": {},
 "nbformat": 4,
 "nbformat_minor": 5
}
